#
# @lc app=leetcode.cn id=88 lang=python3
#
# [88] 合并两个有序数组
#

# @lc code=start
from typing import List
class Solution:
    def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
        """
        Do not return anything, modify nums1 in-place instead.
        """
        nums = nums1[:m].copy()
        i, j, newi = 0, 0, 0
        while i<m and j<n:
            if nums[i]<=nums2[j]:
                nums1[newi] = nums[i]
                i+=1
                newi+=1
            else:
                nums1[newi] = nums2[j]
                j+=1
                newi+=1
        while i<m:
            nums1[newi] = nums[i]
            i+=1
            newi+=1
        while j<n:
            nums1[newi] = nums2[j]
            j+=1
            newi+=1
        return
# @lc code=end

